package com.jsg.sl651.entity.frame.body.report;

import com.jsg.sl651.entity.frame.body.MessageBody;
import com.jsg.sl651.enums.FunctionCode;
import com.jsg.sl651.util.ByteUtil;
import lombok.NoArgsConstructor;
/**
 * 链路维持报
 */
@NoArgsConstructor
public class LinkMaintenanceReport extends ReportMessageBody{
    @Override
    protected MessageBody decodeHex(byte[] bytes) throws Exception {
        if (bytes.length != 8) {
            throw new Exception("链路维持报体长度错误");
        }
        return decodeBasic(bytes);
    }

    @Override
    protected MessageBody decodeAscii(byte[] bytes) throws Exception {
        if (bytes.length != 16) {
            throw new Exception("链路维持报体长度错误");
        }
        return decodeBasic(ByteUtil.asciiHex(bytes));
    }



    @Override
    public int getFunctionCode() {
        return FunctionCode.LINK_MAINTENANCE.getCode();
    }
}
